a = input()
op = "([{<"
cl = ")]}>"
sk = {")": "(", "]": "[", "}": "{", ">": "<"}
stack = []
for i in a:
    if i in op or i in cl:
        if i in op:
            stack.append(i)
        elif sk[i] != stack[-1]:
            print("False")
            exit()
        else:
            stack.pop()
if not stack:
    print("True")
else:
    print("False")
